<template>
    <dv-border-box-7  :color="['#084FA0','#06073B']" style="height: 262px;margin-bottom: 14px;">
        <div class="longcare-box">
        <div class="title-box">
            <span>长护险服务</span>
        </div>
        <div class="container">
            <!-- 意向客户模块 -->
            <div>
                <div class="sub-title-intention-customer">
                    <span>意向客户转换率</span>
                </div>
                <div class="funnel" ref="funnel"></div>
            </div>
            <!-- 服务人员和服务对象模块 -->
            <div class="serve-box">
                <div class="sub-title-serve-people">
                    <span>服务人员数量</span>
                    <div>
                        <div class="text-box">
                            <span>普通护理员</span>
                            <span>4064人</span>
                        </div>
                        <div class="text-box" style="margin-top: 5px;">
                            <span>医疗护理员</span>
                            <span>270人</span>
                        </div>
                    </div>

                </div>
                <div class="sub-title-serve-people">
                    <span>服务对象数量</span>
                    <div class="obj-num-box">
                        <div class="text-box">
                            <span>重度失能人员</span>
                            <span>7008人</span>
                        </div>
                        <div class="text-box" style="margin-top: 5px;">
                            <span>中度失能人员</span>
                            <span>15021人</span>
                        </div>
                        <div class="text-box" style="margin-top: 5px;">
                            <span>中重转轻人员</span>
                            <span>2138人</span>
                        </div>
                    </div>

                </div>
            </div>
        </div>

    </div>
    </dv-border-box-7>

</template>

<script>
import * as echarts from "echarts"

export default {
    data() {
        return {

        }
    },
    mounted() {
        // 拿到漏斗的dom
        const funnel = document.querySelector(".funnel")
        console.log(funnel, "<<<===funnel的dom");
        const funnelEchart = echarts.init(funnel)

        const options = {
            tooltip: {
                backgroundColor:"rgba(50,50,50,0.4)",
                textStyle:{
                    color:"#fff"
                },
                show: true,
                trigger: "item",
                formatter: function (params) {
                    return `${params.data.name}:${params.data.num}人`
                }
            },
            series: [
                {
                    type: "funnel",
                    left: "0%",
                    top: "10%",
                    bottom: "0%",
                    width: "100%",
                    min: 0,
                    max: 100,
                    minSize: "30%",
                    maxSize: "100%",
                    sort: "descending",
                    gap: 4,
                    orient: "vertical",
                    label: {
                        show: true,
                        color: "#fff",
                        position: "inside",
                        formatter: function (params) {
                            return params.data.name + "\n"+ params.data.value + "%"
                        }
                    },
                    itemStyle: {
                        borderColor: "transparent"
                    },
                    data: [
                        {
                            name: "意向",
                            value: 80,//value值用来保持金字塔形状
                            num: 0,//真正的数据
                            itemStyle:{
                                color:"#87AF29",


                                // height:"25%"
                            }
                        },
                        {
                            name: "申请",
                            value: 60,
                            num: 0,
                            itemStyle:{
                                color:"#0DDE9C"
                            }
                        },
                        {
                            name: "评估通过",
                            value: 40,
                            num: 0,
                            itemStyle:{
                                color:"#1CDBFE"
                            }
                        },
                        {
                            name: "正式服务",
                            value: 20,
                            num: 0,
                            itemStyle:{
                                color:"#0E8BFF"
                            }
                        },
                    ]
                },

            ]

        }

        funnelEchart.setOption(options)
    }
}

</script>

<style lang="scss" scoped>
.dv-border-box-7{
    border-radius: 3px;
}

:deep(.dv-border-svg-container) {
  display: none;
}

.longcare-box {
    box-sizing: border-box;
    // background-color: pink;
    height: 100%;
    // border: 1px solid red;
}

.title-box {
    margin-top: 20px;
    margin-left: 41px;

    & span {
        font-size: 22px;
        color: #1CDBFE;
        font-family: SourceHanSansCN-Light;
    }

    ;

    & span::before {
        content: "";
        display: block;
        position: absolute;
        top: -3px;
        left: 17px;
        width: 13px;
        height: 27px;
        background-color: #1CDBFE;
        border-radius: 6px;
    }
}

.container {
    display: flex;
    flex-direction: row;
}

.sub-title-intention-customer {
    position: relative;
    margin-top: 12px;
    margin-left: 62px;

    & span {
        color: #1CDBFE;
        font-size: 17px;
        letter-spacing: 1px;
    }

    ;

    & span::before {
        content: "";
        position: absolute;
        height: 8px;
        width: 8px;
        border-right: 1px solid #1CDBFE;
        border-top: 1px solid #1CDBFE;
        transform: rotate(45deg);
        top: 4px;
        left: -20px;
    }

    ;

    & span::after {
        content: "";
        position: absolute;
        height: 8px;
        width: 8px;
        transform: rotate(45deg);
        border-right: 1px solid #1CDBFE;
        border-top: 1px solid #1CDBFE;
        top: 4px;
        left: -14px;
    }
}

.funnel {
    margin-left: 30px;
    height: 170px;
    width: 100%;
    // border: 1px solid red;
}

.serve-box {
    flex: 1;
    // border: 1px solid greenyellow;

    .sub-title-serve-people {
        position: relative;
        margin-top: 12px;
        margin-left: 32px;
        & >span {
        color: #1CDBFE;
        font-size: 17px;
        letter-spacing: 1px;
    };
    & >span::before {
        content: "";
        position: absolute;
        height: 8px;
        width: 8px;
        border-right: 1px solid #1CDBFE;
        border-top: 1px solid #1CDBFE;
        transform: rotate(45deg);
        left: -20px;
        top: 4px;
    };
    & >span::after {
        content: "";
        position: absolute;
        height: 8px;
        width: 8px;
        transform: rotate(45deg);
        border-right: 1px solid #1CDBFE;
        border-top: 1px solid #1CDBFE;
        left: -14px;
        top: 4px;
    }

    }
}

.text-box{
    // margin-top: 14px;
    & span:first-child{
        color:#418BD4;
        margin-right: 41px;
    };
    &:first-child{
        margin-top: 14px;
    }
}

.obj-num-box .text-box{
    & span:first-child{
        color:#418BD4;
        margin-right: 25px;
    };
    &:first-child{
        margin-top: 14px;
    }
}








</style>
